<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveSupport::CoreExtensions::Date::Calculations</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveSupport::CoreExtensions::Date::Calculations</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Enables the use of time calculations within Time itself
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000688">advance</a>&nbsp;&nbsp;
      <a href="#M000680">ago</a>&nbsp;&nbsp;
      <a href="#M000686">at_beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000703">at_beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000707">at_beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000700">at_beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000709">at_beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000705">at_end_of_month</a>&nbsp;&nbsp;
      <a href="#M000685">at_midnight</a>&nbsp;&nbsp;
      <a href="#M000683">beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000702">beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000706">beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000698">beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000708">beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000689">change</a>&nbsp;&nbsp;
      <a href="#M000687">end_of_day</a>&nbsp;&nbsp;
      <a href="#M000704">end_of_month</a>&nbsp;&nbsp;
      <a href="#M000682">in</a>&nbsp;&nbsp;
      <a href="#M000696">last_month</a>&nbsp;&nbsp;
      <a href="#M000694">last_year</a>&nbsp;&nbsp;
      <a href="#M000684">midnight</a>&nbsp;&nbsp;
      <a href="#M000699">monday</a>&nbsp;&nbsp;
      <a href="#M000690">months_ago</a>&nbsp;&nbsp;
      <a href="#M000691">months_since</a>&nbsp;&nbsp;
      <a href="#M000697">next_month</a>&nbsp;&nbsp;
      <a href="#M000701">next_week</a>&nbsp;&nbsp;
      <a href="#M000695">next_year</a>&nbsp;&nbsp;
      <a href="#M000681">since</a>&nbsp;&nbsp;
      <a href="#M000711">tomorrow</a>&nbsp;&nbsp;
      <a href="#M000692">years_ago</a>&nbsp;&nbsp;
      <a href="#M000693">years_since</a>&nbsp;&nbsp;
      <a href="#M000710">yesterday</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Calculations/ClassMethods.html" class="link">ActiveSupport::CoreExtensions::Date::Calculations::ClassMethods</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000688" class="method-detail">
        <a name="M000688"></a>

        <div class="method-heading">
          <a href="#M000688" class="method-signature">
          <span class="method-name">advance</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Provides precise Date calculations for years, months, and days. The
<tt>options</tt> parameter takes a hash with any of these keys: :years,
:months, :weeks, :days.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000688-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000688-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 72</span>
72:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
73:           <span class="ruby-identifier">d</span> = <span class="ruby-keyword kw">self</span>
74:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:years</span>) <span class="ruby-operator">*</span> <span class="ruby-value">12</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:years</span>]
75:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:months</span>)     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:months</span>]
76:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span>  <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:weeks</span>) <span class="ruby-operator">*</span> <span class="ruby-value">7</span>  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:weeks</span>]
77:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span>  <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:days</span>)       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:days</span>]
78:           <span class="ruby-identifier">d</span>
79:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000680" class="method-detail">
        <a name="M000680"></a>

        <div class="method-heading">
          <a href="#M000680" class="method-signature">
          <span class="method-name">ago</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts Date to a Time (or DateTime if necessary) with the time portion
set to the beginning of the day (0:00) and then subtracts the specified
number of seconds
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000680-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000680-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 30</span>
30:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ago</span>(<span class="ruby-identifier">seconds</span>)
31:           <span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">since</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">seconds</span>)
32:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000686" class="method-detail">
        <a name="M000686"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_day</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000683">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000703" class="method-detail">
        <a name="M000703"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000702">beginning_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000707" class="method-detail">
        <a name="M000707"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_quarter</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000706">beginning_of_quarter</a>
</p>
        </div>
      </div>

      <div id="method-M000700" class="method-detail">
        <a name="M000700"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_week</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000698">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000709" class="method-detail">
        <a name="M000709"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_year</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000708">beginning_of_year</a>
</p>
        </div>
      </div>

      <div id="method-M000705" class="method-detail">
        <a name="M000705"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000704">end_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000685" class="method-detail">
        <a name="M000685"></a>

        <div class="method-heading">
          <span class="method-name">at_midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000683">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000683" class="method-detail">
        <a name="M000683"></a>

        <div class="method-heading">
          <a href="#M000683" class="method-signature">
          <span class="method-name">beginning_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts Date to a Time (or DateTime if necessary) with the time portion
set to the beginning of the day (0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000683-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000683-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 42</span>
42:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_day</span>
43:           <span class="ruby-identifier">to_time</span>
44:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000702" class="method-detail">
        <a name="M000702"></a>

        <div class="method-heading">
          <a href="#M000702" class="method-signature">
          <span class="method-name">beginning_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new ; DateTime objects will have time set to 0:00DateTime
representing the start of the month (1st of the month; DateTime objects
will have time set to 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000702-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000702-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 152</span>
152:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_month</span>
153:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>)
154:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000706" class="method-detail">
        <a name="M000706"></a>

        <div class="method-heading">
          <a href="#M000706" class="method-signature">
          <span class="method-name">beginning_of_quarter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the start of the quarter (1st of
january, april, july, october; DateTime objects will have time set to 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000706-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000706-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 165</span>
165:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_quarter</span>
166:           <span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">10</span>, <span class="ruby-value">7</span>, <span class="ruby-value">4</span>, <span class="ruby-value">1</span>].<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span> })
167:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000698" class="method-detail">
        <a name="M000698"></a>

        <div class="method-heading">
          <a href="#M000698" class="method-signature">
          <span class="method-name">beginning_of_week</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the &quot;start&quot; of this week
(i.e, Monday; DateTime objects will have time set to 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000698-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000698-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 136</span>
136:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_week</span>
137:           <span class="ruby-identifier">days_to_monday</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday!</span>=<span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday</span><span class="ruby-operator">-</span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">6</span>
138:           <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">days_to_monday</span>
139:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">midnight</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">result</span>
140:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000708" class="method-detail">
        <a name="M000708"></a>

        <div class="method-heading">
          <a href="#M000708" class="method-signature">
          <span class="method-name">beginning_of_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the start of the year (1st of
january; DateTime objects will have time set to 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000708-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000708-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 171</span>
171:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_year</span>
172:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>)
173:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000689" class="method-detail">
        <a name="M000689"></a>

        <div class="method-heading">
          <a href="#M000689" class="method-signature">
          <span class="method-name">change</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date where one or more of the elements have been changed
according to the <tt>options</tt> parameter.
</p>
<p>
Examples:
</p>
<pre>
  Date.new(2007, 5, 12).change(:day =&gt; 1)                  # =&gt; Date.new(2007, 5, 1)
  Date.new(2007, 5, 12).change(:year =&gt; 2005, :month =&gt; 1) # =&gt; Date.new(2005, 1, 12)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000689-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000689-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 87</span>
87:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">options</span>)
88:           <span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(
89:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:year</span>]  <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span>,
90:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:month</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>,
91:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:day</span>]   <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">day</span>
92:           )
93:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000687" class="method-detail">
        <a name="M000687"></a>

        <div class="method-heading">
          <a href="#M000687" class="method-signature">
          <span class="method-name">end_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts Date to a Time (or DateTime if necessary) with the time portion
set to the end of the day (23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000687-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000687-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 50</span>
50:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_day</span>
51:           <span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">end_of_day</span>
52:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000704" class="method-detail">
        <a name="M000704"></a>

        <div class="method-heading">
          <a href="#M000704" class="method-signature">
          <span class="method-name">end_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the end of the month (last day of
the month; DateTime objects will have time set to 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000704-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000704-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 158</span>
158:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_month</span>
159:           <span class="ruby-identifier">last_day</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">days_in_month</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span> )
160:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_day</span>, <span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_day</span>)
161:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000682" class="method-detail">
        <a name="M000682"></a>

        <div class="method-heading">
          <span class="method-name">in</span><span class="method-args">(seconds)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000681">since</a>
</p>
        </div>
      </div>

      <div id="method-M000696" class="method-detail">
        <a name="M000696"></a>

        <div class="method-heading">
          <a href="#M000696" class="method-signature">
          <span class="method-name">last_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000690">months_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000696-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000696-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 126</span>
126:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_month</span>
127:           <span class="ruby-identifier">months_ago</span>(<span class="ruby-value">1</span>)
128:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000694" class="method-detail">
        <a name="M000694"></a>

        <div class="method-heading">
          <a href="#M000694" class="method-signature">
          <span class="method-name">last_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000692">years_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000694-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000694-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 116</span>
116:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_year</span>
117:           <span class="ruby-identifier">years_ago</span>(<span class="ruby-value">1</span>)
118:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000684" class="method-detail">
        <a name="M000684"></a>

        <div class="method-heading">
          <span class="method-name">midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000683">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000699" class="method-detail">
        <a name="M000699"></a>

        <div class="method-heading">
          <span class="method-name">monday</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000698">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000690" class="method-detail">
        <a name="M000690"></a>

        <div class="method-heading">
          <a href="#M000690" class="method-signature">
          <span class="method-name">months_ago</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the time a number of specified
months <a href="Calculations.html#M000680">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000690-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000690-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 96</span>
96:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_ago</span>(<span class="ruby-identifier">months</span>)
97:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">months</span>)
98:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000691" class="method-detail">
        <a name="M000691"></a>

        <div class="method-heading">
          <a href="#M000691" class="method-signature">
          <span class="method-name">months_since</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the time a number of specified
months <a href="Calculations.html#M000682">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000691-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000691-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 101</span>
101:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_since</span>(<span class="ruby-identifier">months</span>)
102:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">months</span>)
103:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000697" class="method-detail">
        <a name="M000697"></a>

        <div class="method-heading">
          <a href="#M000697" class="method-signature">
          <span class="method-name">next_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000691">months_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000697-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000697-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 131</span>
131:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_month</span>
132:           <span class="ruby-identifier">months_since</span>(<span class="ruby-value">1</span>)
133:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000701" class="method-detail">
        <a name="M000701"></a>

        <div class="method-heading">
          <a href="#M000701" class="method-signature">
          <span class="method-name">next_week</span><span class="method-args">(day = :monday)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the start of the given day <a
href="Calculations.html#M000682">in</a> next week (default is Monday).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000701-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000701-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 145</span>
145:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_week</span>(<span class="ruby-identifier">day</span> = <span class="ruby-identifier">:monday</span>)
146:           <span class="ruby-identifier">days_into_week</span> = { <span class="ruby-identifier">:monday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:tuesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:wednesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">:thursday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">:friday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>, <span class="ruby-identifier">:saturday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span>, <span class="ruby-identifier">:sunday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">6</span>}
147:           <span class="ruby-identifier">result</span> = (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-value">7</span>).<span class="ruby-identifier">beginning_of_week</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">days_into_week</span>[<span class="ruby-identifier">day</span>]
148:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-identifier">:time</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">result</span>
149:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000695" class="method-detail">
        <a name="M000695"></a>

        <div class="method-heading">
          <a href="#M000695" class="method-signature">
          <span class="method-name">next_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000693">years_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000695-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000695-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 121</span>
121:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_year</span>
122:           <span class="ruby-identifier">years_since</span>(<span class="ruby-value">1</span>)
123:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000681" class="method-detail">
        <a name="M000681"></a>

        <div class="method-heading">
          <a href="#M000681" class="method-signature">
          <span class="method-name">since</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Converts Date to a Time (or DateTime if necessary) with the time portion
set to the beginning of the day (0:00) and then adds the specified number
of seconds
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000681-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000681-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 36</span>
36:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
37:           <span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
38:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000711" class="method-detail">
        <a name="M000711"></a>

        <div class="method-heading">
          <a href="#M000711" class="method-signature">
          <span class="method-name">tomorrow</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Date/DateTime representing the time
1 day <a href="Calculations.html#M000681">since</a> the instance time
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000711-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000711-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 182</span>
182:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tomorrow</span>
183:           <span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
184:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000692" class="method-detail">
        <a name="M000692"></a>

        <div class="method-heading">
          <a href="#M000692" class="method-signature">
          <span class="method-name">years_ago</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the time a number of specified
years <a href="Calculations.html#M000680">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000692-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000692-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 106</span>
106:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_ago</span>(<span class="ruby-identifier">years</span>)
107:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">years</span>)
108:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000693" class="method-detail">
        <a name="M000693"></a>

        <div class="method-heading">
          <a href="#M000693" class="method-signature">
          <span class="method-name">years_since</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Date/DateTime representing the time a number of specified
years <a href="Calculations.html#M000682">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000693-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000693-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 111</span>
111:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_since</span>(<span class="ruby-identifier">years</span>)
112:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">years</span>)
113:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000710" class="method-detail">
        <a name="M000710"></a>

        <div class="method-heading">
          <a href="#M000710" class="method-signature">
          <span class="method-name">yesterday</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Date/DateTime representing the time
1 day <a href="Calculations.html#M000680">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000710-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000710-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb, line 177</span>
177:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yesterday</span>
178:           <span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
179:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>